<template>
  <view>
    <card-dial v-if="mantles && mantles.length" :list="mantles" title="维保责任人"
               :imgSrc="require('@/static/images/index/sign.png')"></card-dial>
    <view class="text_tit">该电梯下所有已计划的且未完成的保养任务</view>
    <view>
      <view class="tabMonth">
        <view class="tabMonth_M">
          <view class="filterBox">
            <view :class="['typeItem', typeIndex == 1 ? 'act' : '']" @click="changeTypes(1)"
                  :style="{ borderRight: typeIndex == 2 ? 'none' : '' }">
              <image class="ico" src="@/static/images/repairFitting/signMonth.png"
                     v-if="typeIndex == 1" mode=""></image>
              <image class="ico" src="@/static/images/repairFitting/signMonthR.png" v-else mode="">
              </image>
              月历视图
            </view>
            <view :class="['typeItem', typeIndex == 2 ? 'act actRight' : '']" @click="changeTypes(2)">
              <image class="ico" src="@/static/images/repairFitting/list2.png" v-if="typeIndex == 2"
                     mode=""></image>
              <image class="ico" src="@/static/images/repairFitting/list1.png" v-else mode=""></image>
              列表视图
            </view>
          </view>
        </view>
        <view class="tab_down" @click="selectDown" v-if="typeIndex == 1">
          <image src="@/static/images/download.png" alt="" srcset=""
                 mode="" />
          <text>下载计划</text>
        </view>
      </view>
      <!-- 日历组件 -->
      <view class="todayPlus"
            :style="typeIndex === 1 ? 'display:block' : 'display:none'">
        <view class="today" @click="todayClick">
          <image src="@/static/images/index/today.png" mode=""></image>
          <text>今天</text>
        </view>
        <monthPlanCom ref="monthPlanCom" :isSinEle="true" :mheight="mheights" :monthArrs="monthArrs"
                      @select="selectTime" @loadScrollMonth="loadScrollMonth" />
      </view>
      <!-- 列表组件 -->
      <block v-if="typeIndex == 2">
        <view class="tabBox">
          <!-- 任务安排提示 -->
          <view class="orderTips">
            <view>{{ title }}</view>
            <!-- <view>列表视图仅显示未完成保养任务及未来半年内保养计划</view> -->

          </view>
          <!-- 列表 -->
          <view class="orderListMain">
            <view class="" v-if="list.length">
              <view class="content" v-for="(item, index) in list" :key="index">
                <view class="date">
                  {{ item.planDate }}
                  <view class="line"></view>
                </view>
                <view>
                  <order-list v-for="(e, i) in item.dataList" :key="i" :item="e" :tabIdx="tabIdx"
                              :typeIdx="1" :parentIdx="index" :childIdx="i" @userMore="handleUserMore"
                              :elevatorId="elevatorId" @update="restList()">
                  </order-list>
                </view>
              </view>
              <view class="more">- 已经到底了 -</view>
            </view>

            <view class="empty" v-else>
              <view class="img">
                <image src="@/static/images/default.png"></image>
              </view>
              <view class="text">- 暂无相关数据 -</view>
            </view>
          </view>
        </view>

      </block>
    </view>
    <!-- 单梯列表组件 -->
    <listsCom ref="listsCom">
      <!-- 列表 -->
      <view class="orderListMain">
        <view class="" v-if="listComData.length">
          <view class="listTit">电梯保养计划</view>
          <view class="content">
            <view class="content_Tit">
              <view class="date">
                {{ strTimes || '--' }}
                <view class="line"></view>
              </view>
              <view class="date_count">
                共 <text>{{listComData.length}}</text> 个任务
              </view>
            </view>

            <view class="piece">
              <order-list :isListSty="true" v-for="(e, i) in listComData" :key="i" :item="e" :tabIdx="tabIdx"
                          :typeIdx="1" :parentIdx="0" :childIdx="i" @userMore="handleUserMore"
                          :elevatorId="elevatorId" @update="restList()">
              </order-list>
            </view>
          </view>
          <view class="more">- 已经到底了 -</view>
        </view>

        <view class="empty" v-else>
          <view class="img">
            <image src="@/static/images/default.png"></image>
          </view>
          <view class="text">- 暂无相关数据 -</view>
        </view>
      </view>

    </listsCom>

    <!-- 筛选组件 -->
    <filter-drawer :chooseData="choosed" :filterList="filterList" :comfireText="comfireText" :show="showFilter"
                   :keyMap="keyMap" title="保养计划下载设置" mainTips="(请选择需要查看保养计划的时间范围)" ref="filter-drawer" :dateLists="dateLists"
                   :orderType="orderType" :isMainPlan="true" :isFilterList="eleMsg" :countState="countState"
                   :isShowDate="false" @closed="handleClose" @submit="submitFilter" @chooseTag="getResultCount"
                   @defaultReset="defaultReset" @customerOpenTime="customerOpenTime">
      <template v-slot:dateFilterBottom>
        <view class="begin-time" v-if="curValue===10 && (curStartDate || curEndDate)"><text>已选：</text><text>{{formatDisplayTime(curStartDate, curEndDate)}}</text></view>
      </template>
    </filter-drawer>
    <!-- 完成时间 -->
    <time-select
        v-if="selectTimePopup"
        :beforeToday="beforeToday"
        :atterToday="true"
        :isChooseToday="isChooseToday"
        :default-model="timeSelectModel"
        :default-select-time="defaultDate"
        @close="closeSelectTimePopup"></time-select>
    <!-- 下载成功对话框 -->
    <model width="508rpx" :visible="successVisible" title="成功导出保养计划" cancleTxt="复制链接" comfireTxt="直接打开"
           @cancle="copyLink" @comfire="openFile">
      <view class="conte">
        <view class="modelItem"> 你可以直接打开，或者复制链接至 </view>
        <view class="modelItem"> 电脑端浏览器下载。 </view>
      </view>
    </model>

  </view>
</template>

<script>
import cardDial from '@/components/card-dial/card-dial.vue';
import monthPlanCom from '@/components/dateSelect/monthPlanCom.vue';
import OrderList from './eleOrderList.vue';
// import filterModel from './components/filter/index.vue';
import filterDrawer from '@/components/filter-drawer/filterDrawer.vue';
import model from '@/components/model/index.vue';
import timeSelect from '@/pages/index/components/timeSelect.vue';
import listsCom from './listsCom.vue';

import { calendarPlan, calendarPlanExcel, calendarStatisticsCount } from '@/apis/maintains.js';
import { elevtorDetail, elevtorMantles,maintenanceUnfinished } from '@/apis/elevator.js';
import { getRepairCheck,} from '@/apis/statistic.js';
import dayjs from 'dayjs';
import { getNowTime } from '@/utils/utils.js';
export default {
	components:{
		cardDial,
		monthPlanCom,
		OrderList,
		filterDrawer,
		// filterModel,
		model,
		timeSelect,
		listsCom
	},
	data() {
		return {
			// elevatorId:"1614082203923881986",
			// 电梯责任人
			mantles: [],
			eleMsg:{},
			typeIndex:1,
			// 月历数据
			monthArrs: {},
			strTimes:'',
			startDate:'',
			endDate:'',
			// 月历计划单梯数据
			listComData:[],
			tabIdx:0,
			// 列表数据
			list:[],
			title:'',
			// 筛选组件
			tempFilePath: '',
			excelURl: '',
			countState: 0,
			// 计划时间的value值
			curValue: 0,
			// 自定义日期
			curStartDate: '',
			// 自定义日期
			curEndDate: '',
			mheights: 0,
			// 筛选组件
			showFilter: false,
			comfireText: '确定',
			allChecked: true,
			orderType: 0,
			choosed: {},
			chooseArr: [],
			filterList: [],
			keyMap: {},
			dateLists: [
				{ name: '今天', value: 1 },
				{ name: '本周', value: 2 },
				{ name: '本月', value: 3 },
				// { name: '后1个自然月', value: 4 },
				// { name: '后2个自然月', value: 5 },
				// { name: '后3个自然月', value: 6 },
				{ name: '下月', value: 4 },
				{ name: '后3个月', value: 7 },
				{ name: '后6个月', value: 8 },
				{ name: '本年', value: 9 },
				{ name: '自定义时间', value: 10 },
			],
			// 日期组件
			selectTimePopup: false,
			successVisible: false,
			// 日期组件
			beforeToday: true,
			// 日期组件
			isChooseToday: true,
			// 时间选择组件模式
			timeSelectModel: 'date',
			defaultDate: []
		};
	},
	props:{
		elevatorId:{
			type:String,
			default:''
		}
	},
	mounted() {
		uni.getSystemInfo({
			success: (res) => {
				this.mheights = res.windowHeight - 78 - 240;
				// console.log(res,this.safeAreaBottom,666)
			},
		});
		this.fetchEleDetail();
		// 默认加载7个月数据
		this.startDate = dayjs(new Date().getTime() - 1000 * 60 * 60 * 24).subtract(2, 'month').format('YYYY-MM-DD');
		this.endDate = dayjs(new Date().getTime() - 1000 * 60 * 60 * 24).add(4, 'month').format('YYYY-MM-DD');
		this.initPlanDateData([this.elevatorId], this.startDate, this.endDate);
	},
	onShow() {
		// this.fetchOrderList();
	},
	methods:{
		// 查列表信息
		fetchOrderList() {
			uni.showLoading({
				title: '加载中',
				mask: true
			});

			// 这里是任务安排
			// 如果是保养
			maintenanceUnfinished({ elevatorId: this.elevatorId,  }).then(res => {
				uni.hideLoading();
				let title = res.data.title;

				this.title = title;
				// this.list = res.data.list;
				const records = res.data.list || [];
				records.forEach((item) => {
					for (let i = 0; i < item.dataList.length; i++) {
						item.dataList[i].usermore = false;
						if (item.dataList[i].partsName != null) {
							const parts = item.dataList[i].partsName.split('&amp;&amp;');
							item.dataList[i].parts = parts[parts.length - 1];
						}
					}
				});
				this.list = records;
				// this.isCanScroll = this.list.length ? true : false
			});
		},
		// 获取电梯详情 及责任人
		fetchEleDetail() {
			elevtorDetail({ elevatorId: this.elevatorId }).then(res => {
				if (res) {
					this.eleMsg = res.data;
				}
			});
			elevtorMantles({ elevatorId: this.elevatorId }).then(res => {
				if (res) {
					this.mantles = res.data;
				}
			});
		},
		// 切换月历组件
		changeTypes(val) {
			this.typeIndex = val;
			if (val === 1) {
				this.initPlanDateData([this.elevatorId], this.startDate, this.endDate);
			} else {
				this.fetchOrderList();
			}
		},
		//
		handleUserMore(res) {
			// console.log(res,666);
			// console.log(this.list,"list");
			const { parentIdx, childIdx, val } = res;
			try {
				this.list[parentIdx].dataList[childIdx].usermore = val;
			} catch (error) {
				console.log(error);
			}
		},
		//
		restList() {
			this.list = [];
			this.title = '';
			this.fetchOrderList();
		},
		todayClick() {
			this.initPlanDateData([this.elevatorId], this.startDate, this.endDate);
		},
		// 初始加载日历排期数据
		initPlanDateData(elevatorIds = [], startDate, endDate, arrow) {
			console.log(startDate,endDate,'initPlanDateData');
			uni.showLoading({
				title: '加载中',
				icon: 'none'
			});
			calendarPlan({
				elevatorIds,
				startDate,
				endDate
			}).then(res => {
				uni.hideLoading();
				if (res.code === 200) {
					this.monthArrs = res.data || {};
					this.$refs['monthPlanCom'].initDate(this.monthArrs, arrow);
				}
			}).catch(() => {
				uni.hideLoading();
			});
		},
		// 日历滚动加载数据
		loadScrollMonth(obj, count, arrow) {
			console.log('hahhggg', obj, count,);
			let startDate = dayjs(obj.year + '-' + (obj.month > 9 ? obj.month : '0' + obj.month)).format('YYYY-MM-DD');
			let endDate = dayjs(obj.year + '-' + (obj.month > 9 ? obj.month : '0' + obj.month)).add(4, 'month').format('YYYY-MM-DD');
			if (count === -1) {
				endDate = obj.year + '-' + (obj.month > 9 ? obj.month : '0' + obj.month) + '-' + '01';
				startDate = dayjs(obj.year + '-' + (obj.month > 9 ? obj.month : '0' + obj.month)).subtract(3, 'month').format('YYYY-MM-DD');
			}
			// if(inits > 1){
			this.initPlanDateData([this.elevatorId], startDate, endDate, arrow);
			// }
		},
		// 选择日历日期
		selectTime(item, year, month) {
			if (!item.planObj.elevatorCount) {
				uni.showToast({
					title: '该日期无保养计划',
					icon: 'none',
				});
				return;
			}
			this.$refs.listsCom.inits();
			let strTimes = year + '-' + (month > 9 ? month : '0' + month) + '-' + (item.date > 9 ? item.date : '0' + item.date);
			this.strTimes = strTimes.replace(/-/g, '/');
			this.listModle(this.elevatorId, strTimes, strTimes);
		},
		// 月历计划单梯数据
		listModle(elevatorId, startTime, endTime) {
			getRepairCheck({
				elevatorId,
				startTime,
				endTime,
				current: 1,
				size: 10,

			}).then(res => {
				if (res.code === 200) {
					this.listComData = res.data.records || [];
				}
			});
		},
		// 电梯排期下载excel
		initElevatorExcel(elevatorIds, startDate, endDate, type) {
			uni.showLoading({
				title: '下载中',
				icon: 'none'
			});
			calendarPlanExcel({
				elevatorIds,
				startDate,
				endDate,
				type
			}).then(res => {
				uni.hideLoading();
				console.log('calendarPlanExcel', res);
				this.successVisible = true;
				if (res.code === 200) {
					let excelURl = res.data;
					let str = excelURl.split('/')[excelURl.split('/').length - 1];
					this.excelURl = excelURl;
					uni.downloadFile({
						url: res.data,
						filePath: wx.env.USER_DATA_PATH + '/' + str,
						success: (data) => {
							console.log(data, '下载的文件');
							if (data.statusCode === 200) {
								uni.hideLoading();
								// this.tempFilePath = data.tempFilePath;
								this.tempFilePath = data.filePath;
							}
						},
					});
				}
			});
		},
		openFile() {
			console.log(this.tempFilePath, 'this.tempFilePath');
			wx.openDocument({
				filePath: this.tempFilePath,
				showMenu: true,
				fileType: 'xlsx',
				success: () => {
					console.log('打开文档成功');
					this.successVisible = false;
				},
				fail: (err) => {
					console.log(err);
				}
			});
		},
		// 复制链接
		copyLink() {
			wx.setClipboardData({
				data: this.excelURl,
				success: () => {
					wx.getClipboardData({
						success(res) {
							console.log(res.data);
						},
					});
					this.successVisible = false;
				},
			});
		},
		// 自定义日期 --完成时间
		closeSelectTimePopup(res, model) {
			let start = '';
			let end = '';
			if (model) {
				this.timeSelectModel = model;
			}
			if (res) {
				console.log('自定义日期', res);
				if (res.indexOf('-') != -1) {
					const timeArr = res.split('-');
					start = timeArr[0].replaceAll('.', '-');
					end = timeArr[1].replaceAll('.', '-');
				} else {
					const time = res.replaceAll('.', '-');
					start = time;
					end = time;
				}
				const nowDay = getNowTime();
				let nowtime = new Date(nowDay).getTime();
				// let starttime = new Date(start).getTime();
				let endtime = new Date(end).getTime();
				if (endtime >= nowtime && !this.beforeToday && !this.isChooseToday) {
					console.log('包含今天');
					uni.showToast({
						title: '自定义日期范围须小于今天',
						icon: 'none',
					});
					return;
				}
			}
			if (start && end) {
				this.curStartDate = start;
				this.curEndDate = end;
				this.defaultDate = [start, end];
				// 向兄弟组件回显日期
				// eslint-disable-next-line vue/custom-event-name-casing
				// 这里消息会触发handleCount
				uni.$emit('closeTimeSelectPlan', { start, end, value: 10});// 向兄弟组件回显日期
				// 会重复调用，暂时屏蔽
				// let objs = { elevatorIds: [this.elevatorId], planBeginDate: this.curStartDate || '', planEndDate: this.curEndDate || '', cuValue: this.curValue || 3 };
				// this.handleCount(objs);
			}
			this.selectTimePopup = false;
			// uni.$emit("closeTimeSelect", { start, end, optionKey: this.optionKey });
		},

		// 完成筛选
		filterdr(res) {
			console.log(res, 'his.choosed');

			let obj = JSON.parse(JSON.stringify(res.dateObj));
			if (obj.startTime && obj.startTime.indexOf(':') == -1) {
				obj.startTime = obj.startTime + ' 00:00:00';
			}
			if (obj.endTime && obj.endTime.indexOf(':') == -1) {
				obj.endTime = obj.endTime + ' 23:59:59';
			}

			if (obj.planBeginDate && obj.planBeginDate.indexOf(':') == -1) {
				obj.planBeginDate = obj.planBeginDate + ' 00:00:00';
			}
			if (obj.planEndDate && obj.planEndDate.indexOf(':') == -1) {
				obj.planEndDate = obj.planEndDate + ' 23:59:59';
			}
			let planBeginDate = '';
			let planEndDate = '';

			// 处理特殊类型：后6个月和本年
			if (obj.value2 === 8 || obj.value2 === 9) {
				const now = new Date();
				if (obj.value2 === 8) { // 后6个月
					// 从下月1日开始到6个月后的月末
					const startDate = new Date(now.getFullYear(), now.getMonth() + 1, 1);
					const endDate = new Date(now.getFullYear(), now.getMonth() + 7, 0);

					// 格式化日期
					planBeginDate = this.formatDate(startDate);
					planEndDate = this.formatDate(endDate);
				} else if (obj.value2 === 9) { // 本年
					// 本年1月1日到12月31日
					const startDate = new Date(now.getFullYear(), 0, 1);
					const endDate = new Date(now.getFullYear(), 11, 31);

					// 格式化日期
					planBeginDate = this.formatDate(startDate);
					planEndDate = this.formatDate(endDate);
				}
			} else {
				if (!obj.value2 || obj.value2 === 10) {
					obj.value2 = 7;
					planBeginDate = res.dateObj.planBeginDate;
					planEndDate = res.dateObj.planEndDate;
				}
			}
			if ([8,9,10].includes(res.cuValue)) {
				obj.value2 = 7;
			}
			this.initElevatorExcel([this.elevatorId], planBeginDate, planEndDate, obj.value2 - 1);
			this.initPlanDateData([this.elevatorId], this.startDate, this.endDate);
		},
		// 格式化日期的辅助方法
		formatDate(date) {
			const year = date.getFullYear();
			const month = (date.getMonth() + 1).toString().padStart(2, '0');
			const day = date.getDate().toString().padStart(2, '0');
			return `${year}-${month}-${day}`;
		},
		// 格式化显示时间
		formatDisplayTime(start, end) {
			if (!start || !end) return '';

			// 解析日期
			const startDate = new Date(start.replace(/\//g, '-'));
			const endDate = new Date(end.replace(/\//g, '-'));

			const startYear = startDate.getFullYear();
			const startMonth = (startDate.getMonth() + 1).toString().padStart(2, '0');
			const endYear = endDate.getFullYear();
			const endMonth = (endDate.getMonth() + 1).toString().padStart(2, '0');

			// 检查是否跨年度
			if (this.timeSelectModel === 'year') {
				if (startYear === endYear) {
					return `${startYear}`;
				}
				return `${startYear}，${endYear}`;
			}
			// if (startYear !== endYear) {
			// 	return `${startYear}，${endYear}`;
			// }

			// 检查是否为月份的第一天和最后一天
			// const isMonthStart = startDate.getDate() === 1;
			// const isMonthEnd = endDate.getDate() === new Date(endYear, endDate.getMonth() + 1, 0).getDate();
			//
			// 如果是月份的开始和结束，显示年-月格式
			// if (isMonthStart && isMonthEnd &&
			// 	(endDate.getMonth() - startDate.getMonth() > 0 || endYear > startYear)) {
			// 	return `${startYear}-${startMonth}至${endYear}-${endMonth}`;
			// }
			if (this.timeSelectModel === 'month') {
				if (startYear === endYear && startMonth === endMonth) {
					return `${startYear}-${startMonth}`;
				}
				return `${startYear}-${startMonth}至${endYear}-${endMonth}`;
			}
			// 默认显示原始格式
			return `${start}至${end}`;
		},
		// 保存筛选
		submitFilter(res) {
			if (!this.countState) {
				return;
			}
			this.keyMap = res.keyMap;
			this.allChecked = res.allChecked;
			this.choosed = res.choosed;
			this.showFilter = false;
			this.$emit('handleFilterDrawerShow', this.showFilter);

			// this.setChooseArr();
			this.filterdr(res);
			// 初始
			this.$refs['filter-drawer'].mianPlanReset({});
		},
		// 点击标签的时候
		getResultCount(res) {
			console.log(res,'getResultCount');
			if (res.cuValue) {
				this.curValue = res.cuValue;
			}
			// if (res.cuValue == 10) {
			// 	return;
			// }
			this.$nextTick(() => {
				// 原本条件
				// res.choosed.useTypes && res.choosed.useTypes.length && res.hasOwnProperty('value')
				// 判断res是否包含value这个属性
				if (res.choosed.useTypes && res.choosed.useTypes.length && Object.prototype.hasOwnProperty.call(res,'value')) {
					// this.$refs.groupSelect.initData()
				} else {
					console.log('3333333333333333333333311111');
					this.handleCount(res);
				}
			});
		},
		handleResetting() {
			this.comfireText = '确定0个计划';
			this.countState = 0;
			// this.$refs['groupSelect'].handleReset()
		},
		// 打开下载弹窗
		selectDown() {
			this.showFilter = true;
			this.curEndDate = '';
			this.curStartDate = '';
			this.defaultDate = [];
			this.timeSelectModel = 'date';
			let objs = {
				elevatorIds: [this.elevatorId],
				planBeginDate: this.startDate,
				planEndDate: this.endDate,
				cuValue: 3
			};
			console.log('3333333333333333333333322222');
			this.handleCount(objs);
			this.$nextTick(() => {
				this.$refs['filter-drawer'].defaultPlan({ value: 3 });
			});
			this.$emit('handleFilterDrawerShow', this.showFilter);
		},
		handleClose() {
			this.curEndDate = '';
			this.curStartDate = '';
			this.defaultDate = [];
			this.timeSelectModel = 'date';
			this.showFilter = false;
			let obj = {};
			this.chooseArr.forEach(item => {
				if (obj[item.key]) {
					obj[item.key].push(item.value);
				} else {
					obj[item.key] = [];
					obj[item.key].push(item.value);
				}
			});
			this.choosed = obj;
			this.$emit('handleFilterDrawerShow', this.showFilter);
			// this.$refs['filter-drawer'].initData(obj)
		},
		// 弹窗后点击日期
		customerOpenTime(objs) {
			this.selectTimePopup = objs.isState;
		},
		// 重置默认
		defaultReset() {
			this.curEndDate = '';
			this.curStartDate = '';
			this.defaultDate = [];
			this.timeSelectModel = 'date';
			// this.selectArr = []
			// this.filterList[0].list[0].name = '全部电梯'
			this.$refs['filter-drawer'].defaultPlan({ value: 3 });
			let objs = { planBeginDate: '', planEndDate: '', cuValue: 3 };
			this.handleCount(objs);
		},
		// 获取点击筛选条件后的数量总数
		async handleCount(res) {
			// eslint-disable-next-line no-unused-vars
			const { allChecked, choosed, reset, cuValue } = res;
			if (reset) {
				this.handleResetting();
				return;
			}
			if (!cuValue) {
				this.comfireText = '确定0个计划';
				this.countState = 0;
				return;
			}

			let startDate = res.planBeginDate;
			let endDate = res.planEndDate;

			// 处理特殊日期类型：后6个月和本年
			if (cuValue === 8 || cuValue === 9) {
				const now = new Date();
				if (cuValue === 8) { // 后6个月
					// 从下月1日开始到6个月后的月末
					const startDateObj = new Date(now.getFullYear(), now.getMonth() + 1, 1);
					const endDateObj = new Date(now.getFullYear(), now.getMonth() + 7, 0);

					// 格式化日期
					startDate = this.formatDate(startDateObj);
					endDate = this.formatDate(endDateObj);

					// 更新curStartDate和curEndDate用于显示
					this.curStartDate = this.formatDate(startDateObj);
					this.curEndDate = this.formatDate(endDateObj);
				} else if (cuValue === 9) { // 本年
					// 本年1月1日到12月31日
					const startDateObj = new Date(now.getFullYear(), 0, 1);
					const endDateObj = new Date(now.getFullYear(), 11, 31);

					// 格式化日期
					startDate = this.formatDate(startDateObj);
					endDate = this.formatDate(endDateObj);

					// 更新curStartDate和curEndDate用于显示
					this.curStartDate = this.formatDate(startDateObj);
					this.curEndDate = this.formatDate(endDateObj);
				}
			}
			let type = res.cuValue - 1 || 0;
			if ([8,9,10].includes(res.cuValue)) {
				type = 6;
			}
			let params = {
				elevatorIds: [this.elevatorId],
				startDate: startDate,
				endDate: endDate,
				// 日期选择的类型
				type: type,
			};
			if (Object.keys(res).length) {
				console.log(3333333);
				// let resultObjs = removeEmpty(params)
				let count = await this.handleGetCount(params);
				console.log(count,'handleGetCount-handleGetCount-handleGetCount');
				this.countState = count;
				if (count > 0) {
					this.comfireText = `确定${count}个计划`;
				} else {
					console.log('筛选结果为空 请重新选择条件');
					uni.showToast({
						icon: 'none',
						title: '筛选结果为空 请重新选择条件'
					});
					this.countState = 0;
					this.comfireText = '确定0个计划';
				}
			}
		},
		// 获取计划数量
		handleGetCount(objs) {
			return new Promise((resolve) => {
				calendarStatisticsCount(objs).then(res => {
					if (res.code === 200) {
						let arrs = res.data || [];
						resolve(arrs);
					}
				});
			}).catch(() =>([]));
		},
	}
};
</script>
<style>
page {
  background-color: #f6f5f8;
}
</style>
<style lang="scss" scoped>
.conte {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 0rpx 0 40rpx 0;

  .modelItem {
    font-size: 28rpx;
    color: #333333;
  }
}

.todayPlus {
  position: relative;
}
.piece{
  // box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(177,177,177,0.50);
  margin: 0 20rpx;
  border-radius: 8rpx;
}

.today {
  font-size: 26rpx;
  color: #666666;
  position: absolute;
  right: 30rpx;
  top: 12rpx;

  text:nth-of-type(1) {
    color: #333333;
    vertical-align: middle;
  }

  image {
    width: 32rpx;
    height: 32rpx;
    margin-right: 4rpx;
    margin-left: 5rpx;
    vertical-align: middle;
  }
}
.text_tit{
  display: flex;
  // justify-content: center;
  margin: 16rpx;
  color: #666666;
  font-size: 26rpx;

}
.tabBox {

  .typeTag {
    display: flex;
    background-color: #fff;
    padding: 20rpx 0 0rpx 0;

    .typeTag_item {
      display: flex;
      flex: 1;
      justify-content: center;
      align-items: center;
      height: 44rpx;
      color: #999;
      font-size: 32rpx;

      image {
        width: 28rpx;
        height: 28rpx;
        margin-top: 16rpx;
      }
    }

    .typeTag_item:nth-child(1) {
      border-right: 2rpx solid #ccc;
    }

    .active {
      color: #333;
      font-weight: 600;
    }

    .tipStyle {
      padding: 0 16rpx;
      // background: pink;
    }
  }

  .tabs {
    // width: 96%;
    // padding: 0 2%;
    background-color: #ffffff;
    display: flex;
    //    position: sticky;
    // z-index: 99999;
    border-bottom: 2rpx #eee solid;

    &-item {
      height: 84rpx;
      line-height: 83rpx;
      margin: 0 20rpx;
      font-size: 26rpx;
      font-weight: 400;
      border-bottom: 4rpx solid #fff;
      color: #93b1c7;
      transition: 0.4s all;
    }

    .act {
      color: #0091ff;
      // font-weight: bold;
      // height: 60rpx;
      // box-sizing: border-box;
      // padding: 16rpx 20rpx;
      border-color: #0091ff;
      font-size: 30rpx;
    }
  }

}
.orderTips {
  font-size: 26rpx;
  color: #666;
  text-align: center;
  // margin: 20rpx 0;
  padding: 20rpx 0;
}
.orderListMain {

  .content_Tit {
    display: flex;
    justify-content: space-between;

    .date_count {
      font-size: 24rpx;
      color: #666666;
      margin-right: 20rpx;

      text {
        color: #0091FF;
      }
    }
  }

  .date {
    color: #333;
    font-size: 26rpx;
    font-weight: 600;
    padding-left: 40rpx;
    position: relative;
  }

  .line {
    width: 4rpx;
    height: 22rpx;
    background: #333333;
    position: absolute;
    left: 20rpx;
    top: 8rpx;
  }

  .more {
    width: 100%;
    padding: 30rpx 0;
    text-align: center;
    color: #999999;
    font-size: 24rpx;
  }
}
.empty {
  display: flex;
  align-items: center;
  justify-content: center;

  image {
    width: 64rpx;
    height: 64rpx;
  }

  height: 800rpx;
  flex-direction: column;
}
.listTit{
  margin-left:40rpx;
  font-size:32rpx;
  font-weight: 600;
  color:#333;
  margin-bottom:20rpx
}

.tabMonth {
  background: #fff;
  display: flex;
  justify-content: center;
  padding: 20rpx 0;
  align-items: center;
  position: relative;

  .filterBox {
    display: flex;
    font-size: 24rpx;
    color: #666;

    .typeItem {
      // width: 112rpx;
      height: 56rpx;
      border: 2rpx solid #d5d5d5;
      display: flex;
      padding-right: 10rpx;
      align-items: center;
      justify-content: center;
      vertical-align: middle;
      transition: .3s all;

      .ico {
        width: 28rpx;
        height: 28rpx;
        padding: 0 10rpx;
      }
    }

    .typeItem:nth-child(1) {
      border-radius: 28rpx 0rpx 0rpx 28rpx;
    }

    .typeItem:nth-child(2) {
      border-radius: 0rpx 28rpx 28rpx 0rpx;
      border-left: none;
    }

    .act {
      background: #dcf0ff;
      border-color: #0091ff;
      color: #0091ff;
    }

    .actRight {
      border-left: 2rpx solid !important;
    }
  }

  .tab_down {
    font-size: 26rpx;
    color: #666;
    position: absolute;
    right: 20rpx;

    image {
      vertical-align: middle;
      margin-right: 10rpx;
      width: 32rpx;
      height: 32rpx;
    }

    text {
      vertical-align: middle;
    }
  }

}
.begin-time{
  padding: 16rpx 0;
  color: #333333;
  &>text:first-child{
    color: #666666;
  }
}
</style>